package com.tuling.mall.feigndemo.remote;

import com.tuling.mall.feigndemo.vo.OrderVo;
import feign.Feign;
import feign.Request;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;


/**
 * feign 可以单独使用，添加相关依赖就行
 *
 * http://localhost:8055/user/findOrderByUserId/1
 * http://localhost:8848/nacos/
 * @author Fox
 */

public class FeignDemo {

    public static void main(String[] args) {

        //基于json
        // encoder指定对象编码方式，decoder指定对象解码方式。  建造者模式,构建代理对象，生成JDK动态代理对象
        RemoteService service = Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .options(new Request.Options(1000, 3500))
                //.retryer(new Retryer.Default(5000, 5000, 3)),  需要启动端口号为8020的mall-order项目（nacos也要启动)
                .target(RemoteService.class, "http://localhost:8020/");

        System.out.println(service.findOrderByUserId(1));
        
    /*    OrderVo vo = new OrderVo();
        vo.setCommodityCode("C000004");
       // vo.setUserId(1);
        vo.setCount(6);
        vo.setAmount(201);
        service.save(vo);

        System.out.println(service.findOrderByUserId(1));*/
    }

}
